package com.btpn.custody.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/*
 * Tracing activity at daily download and manual download
 */
@Entity
@org.hibernate.annotations.Entity(dynamicInsert=true, dynamicUpdate=true)
@Table(name = "TL_DOWNLOAD")
@NamedQueries({
	@NamedQuery(name  = "DownloadLog.findAll",
				query = "FROM DownloadLog ORDER BY createdDate DESC")
})
public class DownloadLog implements Serializable {
	
	/*=============================================== C O N S T A N T =========================================*/
	private static final long serialVersionUID = -3404536222798404499L;
	public static final String NQ__FIND_ALL = "DownloadLog.findAll";
	
	/*=============================================== M E M B E R =============================================*/
	@Id
	@GeneratedValue
	@Column(name = "__ID")
	private Long id;
	
	@Column(name = "__CREATED_DATE")
	private Date createdDate = new Date();
	
	@Column(name = "__FINISH_DATE")
	private Date finishedDate;
	
	@Column(name = "MANUAL_FOR_DATE")
	private Date downloadForDate;
	
	@Column(name = "USERNAME")
	private String username;
	
	// [MANUAL/DAILY/INIT] - [SUCCESS/FAIL]
	@Column(name = "DETAIL", columnDefinition="VARCHAR(20)")
	private String detail;
	
	@Column(name = "EXCEPTION", columnDefinition="TEXT")
	private String exception;

	public DownloadLog() {
		super();
	}

	public DownloadLog(Date downloadForDate, String username, String detail, String exception) {
		super();
		this.downloadForDate = downloadForDate;
		this.username = username;
		this.detail = detail;
		this.exception = exception;
	}

	/*=============================================== G E T T E R   &   S E T T E R ===========================*/
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public Date getDownloadForDate() {
		return downloadForDate;
	}

	public void setDownloadForDate(Date downloadForDate) {
		this.downloadForDate = downloadForDate;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getDetail() {
		return detail;
	}

	public void setDetail(String detail) {
		this.detail = detail;
	}

	public String getException() {
		return exception;
	}

	public void setException(String exception) {
		this.exception = exception;
	}

	public Date getFinishedDate() {
		return finishedDate;
	}

	public void setFinishedDate(Date finishedDate) {
		this.finishedDate = finishedDate;
	}
}
